import 'package:ch_network/ch_network.dart';
import 'package:ch_router/ch_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'common/index.dart';

Future<void> main() async {
  await _initEnv();
  runApp(MyApp());
}

Future<void> _initEnv() async {
  WidgetsFlutterBinding.ensureInitialized();

  CHRoutes.loadRoutes([RoutePages()]);
}

class MyApp extends StatelessWidget {
  MyApp({super.key});
  bool showSplash = false;

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      builder: (context, child) {
        return MaterialApp.router(
          debugShowCheckedModeBanner: false,
          routerConfig: CHRoutes.routerConfig(
              debugLogDiagnostics: true,
              initialLocation: RouteNames.splash,
              observers: [BotToastNavigatorObserver(), RouteObserverEvent()]),
        );
      },
    );
  }
}

class RouteObserverEvent extends NavigatorObserver {}
